package dp;

import java.util.Arrays;

/**
 * @author : Rookie
 * @description : 最长连续递增
 * @date : 2023/6/30
 */
public class LongestContinuousUpSubSequence {

    public static void main(String[] args) {
        int[] sequence = new int[]{1,3,5,4,7};
        int length = getMaxContinuousUpLength(sequence);
        System.out.println(length);
    }

    private static int getMaxContinuousUpLength(int []sequence) {
        // dp[i]表示以i结尾的最长连续递增子序列的长度
        int[] dp = new int[sequence.length];
        int maxLength = 0;
        // 初始化
        Arrays.fill(dp,1);
        for (int i = 1; i < sequence.length; i++) {
            if (sequence[i] > sequence[i-1]) {
                dp[i] = dp[i-1] + 1;
                maxLength = Math.max(maxLength,dp[i]);
            }
        }

        return maxLength;
    }
}
